<?php

/**
 * This is the model class for table "worker".
 *
 * The followings are the available columns in table 'worker':
 * @property string $worker_id
 * @property string $mobile
 * @property string $password
 * @property string $real_name
 * @property integer $gender
 * @property string $avatar
 * @property string $introduce
 * @property integer $born_year
 * @property string $region
 * @property string $create_time
 * @property string $type_id
 * @property integer $is_delete
 * @property string $update_time
 * @property string $session_id
 * @property integer $is_verify
 * @property string $idcard
 * @property string $pic_idcard
 * @property double $starnum
 * @property double $price
 * @property string $worker_num
 */
class Work extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Work the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'worker';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('gender, born_year, is_delete, is_verify', 'numerical', 'integerOnly'=>true),
			array('starnum, price', 'numerical'),
			array('mobile', 'length', 'max'=>15),
			array('password', 'length', 'max'=>50),
			array('real_name, region, type_id, session_id, idcard, worker_num', 'length', 'max'=>255),
			array('avatar, introduce, create_time, update_time, pic_idcard', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('worker_id, mobile, password, real_name, gender, avatar, introduce, born_year, region, create_time, type_id, is_delete, update_time, session_id, is_verify, idcard, pic_idcard, starnum, price, worker_num', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'worker_id' => 'Worker',
			'mobile' => 'Mobile',
			'password' => 'Password',
			'real_name' => 'Real Name',
			'gender' => 'Gender',
			'avatar' => 'Avatar',
			'introduce' => 'Introduce',
			'born_year' => 'Born Year',
			'region' => 'Region',
			'create_time' => 'Create Time',
			'type_id' => 'Type',
			'is_delete' => 'Is Delete',
			'update_time' => 'Update Time',
			'session_id' => 'Session',
			'is_verify' => 'Is Verify',
			'idcard' => 'Idcard',
			'pic_idcard' => 'Pic Idcard',
			'starnum' => 'Starnum',
			'price' => 'Price',
			'worker_num' => 'Worker Num',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('worker_id',$this->worker_id,true);
		$criteria->compare('mobile',$this->mobile,true);
		$criteria->compare('password',$this->password,true);
		$criteria->compare('real_name',$this->real_name,true);
		$criteria->compare('gender',$this->gender);
		$criteria->compare('avatar',$this->avatar,true);
		$criteria->compare('introduce',$this->introduce,true);
		$criteria->compare('born_year',$this->born_year);
		$criteria->compare('region',$this->region,true);
		$criteria->compare('create_time',$this->create_time,true);
		$criteria->compare('type_id',$this->type_id,true);
		$criteria->compare('is_delete',$this->is_delete);
		$criteria->compare('update_time',$this->update_time,true);
		$criteria->compare('session_id',$this->session_id,true);
		$criteria->compare('is_verify',$this->is_verify);
		$criteria->compare('idcard',$this->idcard,true);
		$criteria->compare('pic_idcard',$this->pic_idcard,true);
		$criteria->compare('starnum',$this->starnum);
		$criteria->compare('price',$this->price);
		$criteria->compare('worker_num',$this->worker_num,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}